//
//  AboutUsViewController.m
//  JinYong_iOS_Store
//
//  Created by 王厚一 on 2017/10/22.
//  Copyright © 2017年 why. All rights reserved.
//


#import "AboutUsViewController.h"

@interface AboutUsViewController ()

@end

@implementation AboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self addTopView];
    [self createUI];
}

#pragma mark - --------------添加头视图----------------
- (void)addTopView{
    UIView * topView = ({
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(0), ActualW(375), ActualH(64))];
        CAGradientLayer * gradientLayer = [CAGradientLayer layer];
        gradientLayer.frame = view.bounds;
        //设置渐变区域的起始和终止位置（范围为0-1）
        gradientLayer.startPoint = CGPointMake(0, 0);
        gradientLayer.endPoint = CGPointMake(1, 0);
        //设置颜色数组
        gradientLayer.colors = @[(__bridge id)RGB(22, 125, 255).CGColor, (__bridge id)RGB(0, 178, 255).CGColor];
        //设置颜色分割点（范围：0-1）
        gradientLayer.locations = @[@(0.0f), @(1.0f)];
        [view.layer addSublayer:gradientLayer];
        view;
    });
    [self.view addSubview:topView];
    
    
    UILabel * title = ({
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(152.5), ActualH(32), ActualW(72), ActualH(17))];
        label.textColor = RGB(255, 255, 255);
        label.textAlignment = NSTextAlignmentLeft;
        label.text = @"关于我们";
        label.font = FontX(FONTSIZE(17));
        label;
    });
    [topView addSubview:title];
    
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(ActualW(10), ActualH(31.5), ActualW(18), ActualH(18))];
    imageView.image = [UIImage imageNamed:@"back"];
    [topView addSubview:imageView];
    
    
    UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(13.5), ActualW(41), ActualH(44))];
    [backButton addTarget:self action:@selector(popAction) forControlEvents:UIControlEventTouchUpInside];
    
    [topView addSubview:backButton];
    
    
}

- (void)createUI {
    UIView * breakView = ({
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(64), ActualW(375), ActualH(10))];
        view.backgroundColor = RGB(240, 240, 240);
        view;
    });
    [self.view addSubview:breakView];
    
    UIScrollView * scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(ActualW(10), ActualH(90), ActualW(355), ActualH((667 - 90)))];
    [self.view addSubview:scrollView];
    
    NSString * string = @"      上海嫣筠网络科技有限公司成立于2017年5月，是一家网络科技性质的公司，主要以商城运营为主要工作核心，旗下产品有金佣生活商城，这是一个集购物和社交娱乐为一体的生活综合性商城网站，商城不在只为购物而购物，也许我们在吃喝玩乐之间就可以买到自己想要买的东西，这个平台在互联网+的理念之下，要做的就是让消费者在这里得到自己想要的，不管是精神物质，还是实质物质。生活就是要玩儿出来、秀出来、买出来、乐出来！这里的工作环境很好，工作设施齐全，领导为人和蔼亲切、公司人员相处融洽，富有创造力和创新能力，这里有优秀的团队，除了领导，分别有前端小组、后端小组、UI小组、运营小组，人力资源部，虽然是一家新型公司，但是却有相当明确的工作目标，在这里工作不仅能够找到自己的方向，而且还能够在工作的同时提高自己软性和硬性的能力，很锻炼人，对于自己是一次不可多得的工作机会。";
    
    UILabel * title = ({
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(0), ActualW(355), ActualH(0))];
        label.textColor = RGB(51, 51, 51);
        label.numberOfLines = 0;
//        label.text = string;
        //计算实际frame大小，并将label的frame变成实际大小
        label.backgroundColor = RGB(255, 255, 255);
//        label.font = FontX(FONTSIZE(12));
        
        
        NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
        paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
        paraStyle.alignment = NSTextAlignmentLeft;
        paraStyle.lineSpacing = 10; //设置行间距
        paraStyle.hyphenationFactor = 1.0;
        
        paraStyle.firstLineHeadIndent = 0.0;
        
        paraStyle.paragraphSpacingBefore = 0.0;
        
        paraStyle.headIndent = 0;
        
        paraStyle.tailIndent = 0;
        
        //设置字间距 NSKernAttributeName:@1.5f
        
        NSDictionary *dic = @{NSFontAttributeName:FontX(FONTSIZE(12)), NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f
                              };
        NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:string attributes:dic];
        label.attributedText = attributeStr;
        
        CGSize size = [label sizeThatFits:CGSizeMake(label.frame.size.width, MAXFLOAT)];
        label.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y, size.width,size.height);
        label;
    });
    
    scrollView.contentSize = title.frame.size;
    
    [scrollView addSubview:title];

}


- (void)popAction {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
